﻿using System;

namespace FluentSpring
{
    public class ConstructorDependencyStep: IDependencyStep
    {
        private ConfigContext configContext;
        private ConfigStep origin;

        public ConstructorDependencyStep(ConfigContext configContext, ConfigStep origin)
        {
            this.configContext = configContext;
            this.origin = origin;
        }

        public ConfigStep To<T>()
        {
            BuilderAction action =
                builder => builder.AddConstructorArgReference(typeof(T).FullName);
            configContext.BuilderActionList.Add(action);
            return origin;
        }

        public ConfigStep To(String refName)
        {
            BuilderAction action =
                builder => builder.AddConstructorArgReference(refName);
            configContext.BuilderActionList.Add(action);
            return origin;
        }


        public ConfigStep To(ObjectFactoryDelegate objectFactoryDelegate)
        {
            BuilderAction action =
                builder => builder.AddConstructorArg(objectFactoryDelegate());
            configContext.BuilderActionList.Add(action);
            return origin;
        }

    }
}
